package com.example.mobilesafe.sw1221.home;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.mobilesafe.sw1221.MainActivity;
import com.example.mobilesafe.sw1221.R;

import org.w3c.dom.Text;

import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash2);

        init();//调用初始化方法




    }

    private void init() {
        TextView tv_version = findViewById(R.id.tv_version);


        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);

            tv_version.setText("当前软件版本号为" + packageInfo.versionName);

        } catch (PackageManager.NameNotFoundException e) {

            e.printStackTrace();

        }
        Timer timer = new Timer();
        TimerTask timerTask = new TimerTask() {

            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, HomeActivity.class);
                startActivity(intent);

                SplashActivity.this.finish();
            }


        };
        timer.schedule(timerTask,3000);




    }

}
